package com.cmo.rzl.triage;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.beetl.sql.core.kit.StringKit;

import com.cmo.rzl.core.base.BaseController;
import com.cmo.rzl.core.jfinal.ext.autoroute.ControllerBind;
import com.cmo.rzl.core.toolbox.Record;
import com.cmo.rzl.core.toolbox.kit.ShardKit;
import com.cmo.rzl.shine.service.QueueTypeService;
import com.cmo.rzl.shine.service.impl.QueueTypeServiceImpl;

@ControllerBind(controllerKey = "/clientqueuetype")
public class ClientQueueTypeController extends BaseController {

	QueueTypeService service=new QueueTypeServiceImpl();
	ShardKit shardkit=new ShardKit();
	
	//根据分诊台ip查询队列列表
	public void listQueueType(){
		//当前电脑ip
		String ip=shardkit.getIpAddr(getRequest());
		if(StringKit.isBlank(ip)){
			renderJson(error(IP_ERROR_MSG));
			return;
		}
		List<Record> list=service.listQueueType(ip);
		if(null==list){
			renderJson(error(QUEUE_TYPE_NULL_MSG));
			return;
		}else{
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("code", 0);
			map.put("msg", QUERY_SUCCESS_MSG);
			map.put("list", list);
			map.put("count", list.size());
			renderJson(map);
		}
	}
	//当前分诊台下的队列名称列表
	public void listQueueTypeName(){
		Map<String, Object> map=new HashMap<String, Object>();
		//当前电脑ip
		String ip=shardkit.getIpAddr(getRequest());
		if(StringKit.isBlank(ip)){
			renderJson(error(NOT_NULL_MSG));
			return;
		}
		
		List<Record> list=service.listQueueTypeName(ip);
		if(list.isEmpty()){
			renderJson(error(QUERY_FAIL_MSG));
			return;
		}else{
			map.put("return_msg", "成功");
			map.put("return_code", "success");
			map.put("list", list);
			renderJson(map);
		}
	}
	
}
